//
//  QDCaseTypeController.m
//  QuickDoctor
//
//  Created by ycw on 2016/12/25.
//  Copyright © 2016年 Eric. All rights reserved.
//

#import "QDCaseTypeController.h"

@interface QDCaseTypeController ()<UITableViewDelegate,UITableViewDataSource>

@property(strong,nonatomic) NSArray<NSString *> *array;

@end

@implementation QDCaseTypeController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"疾病类型";
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setUpUI];
}

#pragma mark
#pragma mark - 搭建界面
- (void) setUpUI
{
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    
    [self.view addSubview:tableView];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
        
    }];
    
    tableView.delegate = self;
    
    tableView.dataSource = self;
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    self.array = @[@"肿瘤科",@"心血管科",@"血液科",@"神经科",@"骨科"];
    
}

#pragma mark
#pragma mark - 实现数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return self.array.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.textLabel.text = self.array[indexPath.row];
    
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (_typeBlock) {
        _typeBlock(self.array[indexPath.row]);
    }
    
    [self.navigationController popViewControllerAnimated:YES];
    
}



@end
